package allen.log;

import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

/**
 * Client can get Log from factory.
 * */
public class LogFactory {

	private static Map<String, Log> loggers = Collections
			.synchronizedMap(new HashMap<String, Log>());

	/**
	 * Get log by log name.
	 * */
	public static Log getLog(String logName) {
		if (loggers.containsKey(logName)) {
			return loggers.get(logName);
		} else {
			UILogger log = new UILogger(logName);
			loggers.put(logName, log);
			return log;
		}
	}

	/**
	 * Get log by class.
	 * */
	public static Log getLog(Class<?> c) {
		return getLog(c.getName());
	}
}
